<%@ include file="IsProff.jsp"%>
<%@ page import="java.io.*, java.text.*, java.util.Date, java.sql.*, javax.servlet.*, javax.servlet.http.*, java.util.*" %>

<%
String usernameSC = (String) session.getAttribute("ProfID");

if(usernameSC == null )
	response.sendRedirect("error.jsp");
%>

<script language="javascript" type="text/javascript">

var previousType = "description";

function show1(type)
{
    if(type != previousType)
     {
	var pre = eval("document.addProject."+previousType);
	pre.value = document.getElementById("txta").value;
	document.getElementById("txta").value = eval("document.addProject."+type+".value");
	document.getElementById(previousType).className = "free";
	document.getElementById(type).className = "choosen";
	previousType = type;
     }
	
}

function openPreviewWindow(x,y,page)
{
	textFill();
	var maxX=screen.width; 
	var maxY= screen.height;
	var wX = window.width;
	var wY = window.height;
	var wdth;
	var heght;
	if(x == 0)
	{
		wdth = maxX - (maxX/4);
		heght = maxY -(maxY/4);
	}
	else
	{
		wdth = x;
		heght = y;
	}	
	window.open(page+".jsp",page,"height="+heght+",width="+wdth+",scrollbar=yes").moveTo((maxX/2)-(wdth/2),(maxY/2)-(heght/2));
	
}

function textFill()
{
	var pre = eval("document.addProject."+previousType);
	pre.value = document.getElementById("txta").value;
}

function addDone()
{
        
	textFill();
	var div = document.getElementById("errorAdd");
	if(document.addProject.title.value=="")
	{
		div.innerHTML = "<font style='background-color: white; font-size:12pt' face='Arial' color = 'red'>Your project details are not compelete, please check the title field!</font>";
		
		return false;
	}
	else if(document.addProject.description.value=="")
	{
		div.innerHTML = "<font style='background-color: white; font-size:12pt' face='Arial' color = 'red'>Your project details are not compelete, please check the description field!</font>";
		
		return false;
	}
	else if(document.addProject.project_objectives.value=="")
	{
		div.innerHTML = "<font style='background-color: white; font-size:12pt' face='Arial' color = 'red'>Your project details are not compelete, please check the project objectives field!</font>";
		
		return false;
	}
	else if(document.addProject.required_background.value=="")
	{
		div.innerHTML = "<font style='background-color: white; font-size:12pt' face='Arial' color = 'red'>Your project details are not compelete, please check the required background field!</font>";
		
		return false;
	}
	else if(document.addProject.tools_needed.value=="")
	{
		div.innerHTML = "<font style='background-color: white; font-size:12pt' face='Arial' color = 'red'>Your project details are not compelete, please check the tools needed field!</font>";
		
		return false;
	}
	else if(document.addProject.project_type.value=="")
	{
		div.innerHTML = "<font style='background-color: white; font-size:12pt' face='Arial' color = 'red'>Your project details are not compelete, please check the project type field!</font>";
		
		return false;
	}
	else if(document.addProject.project_keywords.value=="")
	{
		div.innerHTML = "<font style='background-color: white; font-size:12pt' face='Arial' color = 'red'>Your project details are not compelete, please check the project keywords field!</font>";
		
		return false;
	}
	else if(document.addProject.expected_results.value=="")
	{
		div.innerHTML = "<font style='background-color: white; font-size:12pt' face='Arial' color = 'red'>Your project details are not compelete, please check the expected result field!</font>";
		
		return false;
	}
		
		
	//onfocus="resetError()"
	return true;
}

function resetError()
{
	var div = document.getElementById("errorAdd");
	div.style.bgcolor = "white";
	div.innerHTML = "";
}

function onLoadDo()
{
        previousType = "description";
	var output = "";
	var div = document.getElementById("fsize");
	
}

function setB()
{
		document.getElementById('txta').value += "<b> </b>";
}
function setU()
{
		document.getElementById('txta').value += "<u> </u>";
}
function setI()
{
		document.getElementById('txta').value += "<i> </i>";
}

function setSFC()
{
	var size = document.addProject.fSize.value;
	var style = document.addProject.fStyle.value;
	var color = document.addProject.fColor.value;
	document.getElementById('txta').value += "<font style=\"font-size: "+size+"pt\" face=\""+style+"\" color=\""+color+"\"> </font>";
	
}

function sendP(action)
{
    if(addDone())
    {
        document.addProject.type.value = action;
        document.addProject.submit();
    }
}    

</script>
<center>

<form onsubmit= "return addDone()" name= "addProject" method="POST" action="addP.jsp">

<center><table style="font-size: 10pt;" border="0" height= "50%" width="150" cellspacing="0" cellpadding="0" >
<tr><td align="left" style="color: #000000; font-size: 12pt; padding: 25px" colspan="8"><b>Title:</b>&nbsp;&nbsp;&nbsp;<input style="width:90%; padding: 3px; font-size:12pt; color: #000000" type="text" name= "Title" id= "title">
	</td>
</tr>
<tr>
	<td style="border-left: solid 2px #877065" id="description" class="choosen" onclick="show1('description')">Description
	</td>
	<td id="project_objectives" class="free" onclick="show1('project_objectives')">Project<br>Objectives
	</td>
	<td id="required_background" class="free" onclick="show1('required_background')">Required<br>Background
	</td>
	<td id="tools_needed" class="free" onclick="show1('tools_needed')">Tools<br>Needed
	</td>
	<td id="difficulty_level" class="free" onclick="show1('difficulty_level')">Difficulity<br>Level
	</td>
	<td id="project_type" class="free" onclick="show1('project_type')">Project<br>Type
	</td>
	<td id="project_keywords" class="free" onclick="show1('project_keywords')">Project<br>Keywords
	</td>
	<td id="expected_results" class="free" onclick="show1('expected_results')">Expected<br>Results
	</td>
	<td style="border-right: solid 2px #877065" id="additional_comments" class="free" onclick="show1('additional_comments')">Additional<br>Comments
	</td>
</tr>	
<tr>
	
</tr>
<tr height="100%" style=" padding: 0px">
	<td style="background-color: #dddddd; border-right: solid 2px #877065; border-left: solid 2px #877065; border-bottom: solid 2px #877065" class="tabsbody" colspan="10">
		<br><center><textarea id= "txta" onchange="textFill()" onfocus="textFill()" wrap="soft" style="font-size:12pt; width:95%; background-color: #eeeeee" ROWS="10"></textarea></center><br>
	</td>
</tr>
<tr colspan="10">
	<td>
		<input type="hidden" name="description"/>
		<input type="hidden" name="project_objectives"/>
		<input type="hidden" name="required_background"/>
		<input type="hidden" name="tools_needed"/>
		<input type="hidden" name="difficulty_level"/>
		<input type="hidden" name="project_type"/>
		<input type="hidden" name="project_keywords"/>
		<input type="hidden" name="expected_results"/>
		<input type="hidden" name="additional_comments"/>
                <input type="hidden" name="type"/>
                
		
		<INPUT TYPE="button" VALUE="Add Image" onclick="alert('Sorry, not available yet.');"/>
	</td>
</tr>
<tr>
	<td colspan="9">
		<center><input type="button" value ="Preview" onclick="openPreviewWindow(0,0,'preview')"/>&nbsp;&nbsp;&nbsp;<input type="button" value =" Save Draft" onclick="sendP('uncompleted')"/>&nbsp;&nbsp;&nbsp;<input type="button" value =" Submit Project" onclick="sendP('pending')"/></center>
	</td>
</tr>
	 </table>
</form>
</center>
<div id="errorAdd"></div>
